/**
 * 
 */
package com.edocbase.desktop.label.providers;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.edocbase.desktop.lightweight.ui.LookAndFeel;
import com.edocbase.webdriver.IWebAccount;
import com.edocbase.webdriver.WebDriverManager;
import com.edocbase.webdriver.mail.MailDriverConfig;

/**
 * @author X61
 *
 */
public class WebAccountLabelProvider extends LabelProvider implements
		ITableLabelProvider {

	/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
	 */
	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
	 */
	@Override
	public String getColumnText(Object element, int columnIndex) {
		IWebAccount account = (IWebAccount)element;
		if (columnIndex == 0){
			return account.getAccount();
		}else if (columnIndex == 1){
			return account.getAccountType();
		}
		return null;
	}

	@Override
	public String getText(Object element) {
		IWebAccount account = (IWebAccount)element;
		return account.getFullAccount();
	}

	@Override
	public Image getImage(Object element) {
		IWebAccount account = (IWebAccount)element;
		MailDriverConfig cfg = WebDriverManager.getManager().getConfig(account);
		String icon = cfg.getIcon();
		if (icon != null){
			return LookAndFeel.getImage("/images/driver/".concat(icon));
		}
		return super.getImage(element);
	}

}
